<template>
  <div class="app-container">
    <el-form ref="postForm" :model="postForm" label-width="120px" label-position="right">
      <el-form-item label="学号">
        <el-input v-model="postForm.student_no" style="width: 300px"/>
      </el-form-item>
      <el-form-item label="发帖人">
        <el-input v-model="postForm.username" style="width: 300px"/>
      </el-form-item>
      <el-form-item label="发帖时间">
        <el-input v-model="postForm.create_time" style="width: 300px"/>
      </el-form-item>
      <el-form-item label="图片">
        <img :src="postForm.image_url" alt="" style="max-height: 100%;max-width: 100%;">
      </el-form-item>
      <el-form-item label="标题">
        <el-input v-model="postForm.title" style="width: 500px"/>
      </el-form-item>
      <el-form-item label="内容">
        <Editor v-model="postForm.content" style="width: 800px"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="$router.back(-1)">返回</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import Editor from '@/components/Editor/ueditor'
import { detail } from '@/api/tiezi'
export default {
  name: 'Edit',
  components: { Editor },
  data() {
    return {
      postForm: {
        id: undefined,
        student_no: '',
        username: '',
        title: '',
        content: '',
        create_time: ''
      }
    }
  },
  created() {
    const id = this.$route.query && this.$route.query.id
    this.fetchData(id)
  },
  methods: {
    fetchData(id) {
      detail({ id: id }).then(res => {
        this.postForm = res.data
      })
    }
  }
}
</script>

<style scoped>

</style>
